package com.sys.SysAlerts.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.sys.common.annotation.Log;
import com.sys.common.core.controller.BaseController;
import com.sys.common.core.domain.AjaxResult;
import com.sys.common.enums.BusinessType;
import com.sys.SysAlerts.domain.SysAlerts;
import com.sys.SysAlerts.service.ISysAlertsService;
import com.sys.common.utils.poi.ExcelUtil;
import com.sys.common.core.page.TableDataInfo;

/**
 * 告警记录Controller
 * 
 * @author ruoyi
 * @date 2025-09-03
 */
@RestController
@RequestMapping("/SysAlerts/SysAlerts")
public class SysAlertsController extends BaseController
{
    @Autowired
    private ISysAlertsService sysAlertsService;

    /**
     * 查询告警记录列表
     */
    @PreAuthorize("@ss.hasPermi('SysAlerts:SysAlerts:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysAlerts sysAlerts)
    {
        startPage();
        List<SysAlerts> list = sysAlertsService.selectSysAlertsList(sysAlerts);
        return getDataTable(list);
    }

    /**
     * 导出告警记录列表
     */
    @PreAuthorize("@ss.hasPermi('SysAlerts:SysAlerts:export')")
    @Log(title = "告警记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysAlerts sysAlerts)
    {
        List<SysAlerts> list = sysAlertsService.selectSysAlertsList(sysAlerts);
        ExcelUtil<SysAlerts> util = new ExcelUtil<SysAlerts>(SysAlerts.class);
        util.exportExcel(response, list, "告警记录数据");
    }

    /**
     * 获取告警记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('SysAlerts:SysAlerts:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(sysAlertsService.selectSysAlertsById(id));
    }

    /**
     * 新增告警记录
     */
    @PreAuthorize("@ss.hasPermi('SysAlerts:SysAlerts:add')")
    @Log(title = "告警记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysAlerts sysAlerts)
    {
        return toAjax(sysAlertsService.insertSysAlerts(sysAlerts));
    }

    /**
     * 修改告警记录
     */
    @PreAuthorize("@ss.hasPermi('SysAlerts:SysAlerts:edit')")
    @Log(title = "告警记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysAlerts sysAlerts)
    {
        return toAjax(sysAlertsService.updateSysAlerts(sysAlerts));
    }

    /**
     * 删除告警记录
     */
    @PreAuthorize("@ss.hasPermi('SysAlerts:SysAlerts:remove')")
    @Log(title = "告警记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(sysAlertsService.deleteSysAlertsByIds(ids));
    }
}
